package com.leyou.page.web;

import com.leyou.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

@Controller
public class PageController {

    @Autowired
    private PageService pageService;

    @GetMapping("item/{id}.html")
    public String hello(Model model, @PathVariable("id") Long id) {
        //查询商品模型数据
        Map<String,Object> itemData = pageService.loadItemData(id);
        //向model中添加模型数据
        model.addAllAttributes(itemData);
        return "item";
    }
}
